
var vm = new Vue({
	el: '#app',
	
	data:{
		varList: [],	//list
		page: [],		//分页类
		keywords:'',	//检索条件,关键词
		showCount: -1,	//每页显示条数(这个是系统设置里面配置的，初始为-1即可，固定此写法)
		currentPage: 1,	//当前页码
		loading:false	//加载状态
    },
    
	methods: {
		
        //初始执行
        init() {
    		this.getList();
        },
        
        //获取列表
        getList: function(){
        	this.loading = true;
        	$.ajax({
        		xhrFields: {
                    withCredentials: true
                },
        		type: "POST",
        		url: httpurl+'signup/list?showCount='+this.showCount+'&currentPage='+this.currentPage,
        		data: {keywords:this.keywords,STATE:"true",tm:new Date().getTime()},
        		dataType:"json",
        		success: function(data){
        		 if("success" == data.result){
        			 vm.varList = data.varList;
        			 vm.page = data.page;
        			 vm.loading = false;
        			 $("input[name='ids']").attr("checked", false);
        		 }else if ("exception" == data.result){
                 	showException("报名管理",data.exception);//显示异常
                 }
        		}
        	}).done().fail(function(){
                swal("登录失效!", "请求服务器无响应，稍后再试", "warning");
                setTimeout(function () {
                	window.location.href = "../../login.html";
                }, 2000);
            });
        },
        
        //检查是否报过名
        hasSignupp: function (SIGNUP_ID,EXAMINE){
        	$.ajax({
        		xhrFields: {
                    withCredentials: true
                },
        		type: "POST",
        		url: httpurl+'signupmx/hasSignupp',
        		data: {SIGNUP_ID:SIGNUP_ID,tm:new Date().getTime()},
        		dataType:"json",
        		success: function(data){
        		 if("success" == data.result){
        			 vm.goAdd(SIGNUP_ID,EXAMINE);
        		 }else if ("error" == data.result){
        			 swal("已经报过名了!", "请不要重复报名", "warning");
                 }else if ("exception" == data.result){
                 	showException("报名管理",data.exception);//显示异常
                 }
        		}
        	});
        },
        
    	//查看报名考试信息
    	showSignup: function (SIGNUP_ID){
    		 var diag = new top.Dialog();
    		 diag.Drag=true;
    		 diag.Title ="报名考试信息";
    		 diag.URL = '../../exam/signup/signup_msg.html?SIGNUP_ID='+SIGNUP_ID;
    		 diag.Width = 800;
    		 diag.Height = 800;
    		 diag.Modal = true;				//有无遮罩窗口
    		 diag. ShowMaxButton = true;	//最大化按钮
    	     diag.ShowMinButton = true;		//最小化按钮 
    		 diag.CancelEvent = function(){ //关闭事件
    			diag.close();
    		 };
    		 diag.show();
    	},
        
    	//报名
    	goAdd: function (SIGNUP_ID,EXAMINE){
    		 var diag = new top.Dialog();
    		 diag.Drag=true;
    		 diag.Title ="报名";
    		 diag.URL = '../../exam/signupmx/signupmx_edit.html?SIGNUP_ID='+SIGNUP_ID+'&EXAMINE='+EXAMINE;
    		 diag.Width = 600;
    		 diag.Height = 300;
    		 diag.Modal = true;				//有无遮罩窗口
    		 diag. ShowMaxButton = true;	//最大化按钮
    	     diag.ShowMinButton = true;		//最小化按钮 
    		 diag.CancelEvent = function(){ //关闭事件
    	    	 var varSon = diag.innerFrame.contentWindow.document.getElementById('showform');
    			 if(varSon != null && varSon.style.display == 'none'){
    				// vm.getList();
    			}
    			diag.close();
    		 };
    		 diag.show();
    	},
        
        //-----分页必用----start
        nextPage: function (page){
        	this.currentPage = page;
        	this.getList();
        },
        changeCount: function (value){
        	this.showCount = value;
        	this.getList();
        },
        toTZ: function (){
        	var toPaggeVlue = document.getElementById("toGoPage").value;
        	if(toPaggeVlue == ''){document.getElementById("toGoPage").value=1;return;}
        	if(isNaN(Number(toPaggeVlue))){document.getElementById("toGoPage").value=1;return;}
        	this.nextPage(toPaggeVlue);
        }
       //-----分页必用----end
		
	},
	
	mounted(){
        this.init();
    }
})